<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
 
<script type="text/javascript">

	$(document).ready(function(){
		$("#deleteForm").submit(function(){
			var c=confirm("정말 탈퇴하시겠습니까?");
			if(c==false){
				return false;
			}
		});
	});
</script>

<c:choose>
		<c:when test="${sessionScope.userInfo==null}">
			<script type="text/javascript">
				//이 아랫줄 코드가 없으면 이 when 문이 먹질 않는데.. 왜그런지 모르겠음ㅜ
				alert(${sessionScope.userInfo});
				alert("로그인 후에 이용가능한 서비스입니다");
				location.href = "${initParam.root}member.do?command=home";
			</script>
		</c:when>
		<c:otherwise>
		<h2>My Page</h2><br>
		<!-- 쪽지함 -->
			<form id="messageBoxForm" action="${initParam.root }message.do" method="post">
				<input type="submit" value="쪽지함">
				<input type="hidden" name="command" value="messageBox">
				<input type="hidden" name="pageRe" value="1">
				<input type="hidden" name="pageSd" value="1">
			</form>

		<!-- 내 거래내역 -->	
			<form id="viewMyTH" action="${initParam.root }member.do">
			<input type="submit" value="내 거래내역">
			<input type="hidden" name="command" value="viewMyTH">
			</form>
			

			<!-- 회원탈퇴 -->
			<form id="deleteForm" action="${initParam.root }member.do">
			<input type="submit" value="회원탈퇴">
			<input type="hidden" name="command" value="delete">
			</form>
			
			<c:if test="${sessionScope.userInfo.grade==admin }">
				<a href="${initParam.root }admin.do?command=moveToMain">관리자 페이지로</a>
			</c:if>
			
		</c:otherwise>
	</c:choose>
